package com.my.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 请求乱码问题
 * GET请求
 * POST请求  通过设置服务器解析编码的格式
 *              req.setCharacterEncoding("utf-8")
 */
@WebServlet("/s02")
public class Servlet02 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取客户端传递的参数
        req.setCharacterEncoding("utf-8");
        String uname = req.getParameter("uname");
        String upwd= req.getParameter("upwd");
        System.out.println("uname:"+uname);
        System.out.println("upwd:"+upwd);
    }
}
